package com.wq.nio.file;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

/**
 * @Author: wangqiang20995
 * @Date:2018/8/31
 * @Description:
 * @Resource:
 */
public class FileCopyWithNio {

    private static final String SOURCE_FILE = "D:\\workResources\\communication\\支付结算\\HUI文档.rar";

    private static final String TARGET_FILE = "D:\\HUI文档.rar";

    public static void main(String args[]) throws IOException {
        RandomAccessFile sourceFile = new RandomAccessFile(SOURCE_FILE, "rw");
        FileChannel sourceChannel = sourceFile.getChannel();

        RandomAccessFile targetFile = new RandomAccessFile(TARGET_FILE, "rw");
        FileChannel targetChannel = targetFile.getChannel();

        System.out.println("copy file from [" + SOURCE_FILE + "] to target [" + TARGET_FILE + "]");
        targetChannel.transferFrom(sourceChannel,0,sourceChannel.size());

        System.out.println(new Double("5000000") > new Double("23.44"));
    }
}
